<template>
  <div>
    <div class="center">
      <div v-for="(item, index) in data" :key="index">
        <div class="toptitle">{{ item.mold }}</div>
        <div
          class="center_list"
          v-for="(subItem, subIndex) in item.ptype"
          :key="subIndex"
          :style="subIndex > 0 ? 'margin-top: 15px' : ''"
          @click="redirection(item.mold, subItem.mold, subItem.type)"
        >
          <div class="center_txt">
            {{ subItem.id }}
            <div class="center_txt_img">
              <img src="../icon/33.png" alt="" />
            </div>
            <div class="center_txt_title">{{ subItem.mold }}</div>
          </div>
          <div class="center_img">
            <img src="../icon/32.png" alt="" />
          </div>
        </div>
      </div>
    </div>
    <div class="bottom" @click="$router.go(-1)">返回上一页</div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      data: [],
    };
  },
  mounted() {
    const { id, title } = this.$route.query;
    // console.log({ id, title });
    this.$http.get(`/api/mzcy/question/clss?id=${id}`).then((res) => {
      // console.log(res.data);
      if (res.data.code === 200) {
        this.data = Object.keys(res.data.data).reduce((pre, curr) => {
          return pre.concat(res.data.data[curr]);
        }, []);
      }
    });
  },
  methods: {
    redirection: function (pidTitle, title, type) {
      this.$router.push({
        path: "/examinationpage",
        query: {
          pid: this.$route.query.id,
          type,
          pidTitle: pidTitle,
          title,
          status: this.$route.query.status,
        },
      });
    },
  },
};
</script>

<style scoped>
@import url("../css/practiceList.css");
</style>
